import {mapGetters} from 'vuex'

export default {
	watch: {
	    // 监听 total 变化
	    total: {
	      handler(newVal) {
	        this.setBadge();
	      },
	      immediate: true
		}
	},
	computed:{
		...mapGetters('m_cart',['total'])
	},
	onShow(){
		this.setBadge()
	},
	methods:{
		setBadge(){
			uni.setTabBarBadge({
				index:2,
				 text: this.total.toString() || '0'
				
			})
		}
	}
}